package net.sx.minemodule.mvp.activities;


import android.os.Bundle;
import android.widget.ImageButton;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.homegoods.aroutercomment.ARouterPath;
import com.homegoods.aroutercomment.UserService;
import com.kedll.library.base.MyBaseFragmentActivity;

import net.sx.minemodule.R;
import net.sx.minemodule.databinding.MineActivityMinePackageBinding;
import net.sx.minemodule.mvp.presenters.MinePackagePresenter;
import net.sx.minemodule.mvp.views.MinePackageView;


/**
 * 我的钱包
 *
 * @author 11470
 */
@Route(path = ARouterPath.PATH_MINE_PACKAGE)
public class MinePackageActivity extends MyBaseFragmentActivity<MineActivityMinePackageBinding, MinePackagePresenter> implements MinePackageView {
    @Autowired(name = ARouterPath.PATH_USER_SERVICE)
    public UserService userService;

    @Override
    protected MinePackagePresenter getPresenter() {
        return new MinePackagePresenter(this);
    }

    @Override
    protected int getLayout() {
        return R.layout.mine_activity_mine_package;
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        ARouter.getInstance().inject(this);
        ImageButton imageButton = new ImageButton(this);
        imageButton.setImageResource(R.drawable.ic_arrow_back_white);

        mBinding.tvMoneyMinePackage.setText(userService.getBalance());
    }

    @Override
    protected void initEvent() {
        //返回
        mBinding.ivBackPackage.setOnClickListener(v -> finish());

        //常见问题
        mBinding.tvRightQuestion.setOnClickListener(v ->
                ARouter.getInstance().build(ARouterPath.PATH_MINE_COMMON_QUESTION).navigation());

        //充值
        mBinding.rlnPayLayoutPackage.setOnClickListener(v -> {
            ARouter.getInstance().build(ARouterPath.PATH_MINE_PACKAGE_PAY).navigation();
        });

        //提现
        mBinding.rlnWithdrawPackage.setOnClickListener(v -> {
            ARouter.getInstance().build(ARouterPath.PATH_MINE_PACKAGE_WITH_DRAW).withString("balance", userService.getBalance()).navigation();
        });

        //明细
        mBinding.rlnInfoPackage.setOnClickListener(v -> {
            ARouter.getInstance().build(ARouterPath.PATH_MINE_PACKAGE_INFO).navigation();
        });

        //银行卡
        mBinding.rlnCardPackage.setOnClickListener(v -> {
            ARouter.getInstance().build(ARouterPath.PATH_MINE_CARD_PACKAGE).navigation();
        });

    }

}
